package com.guanjialhx.config;

import com.wechat.pay.java.core.util.IOUtil;
import com.wechat.pay.java.core.util.PemUtil;

import java.security.PrivateKey;

/**
 * 微信支付参数配置类
 */
public class WeiXinConfig {
    /** 商户号 */
    public static String MERCHANT_ID = "1662200355";
    /** 商户APIV3密钥 */
    public static String API_V3_KEY = "CHJKGUANJIA2024MIIELjCCAxagAwIBA";
    /** 商户API私钥路径 */
//    public static String MERCHANT_PRIVATE_KEY_PATH = "src/main/resources/wxPayConfig/apiclient_key.pem";
    public static String MERCHANT_PRIVATE_KEY_PATH = "/opt/GuanJia/WeiXin/apiclient_key.pem";//生产环境路径
    /** 商户证书序列号 */
    public static String MERCHANT_SERIAL_NUMBER = "5ADFD979F79E39534896BE9C30940DAB6EC3AE90";
    //支付完成后的回调的地址(如果不要回调信息,可以不配置)
    public static final String PAY_NOTIFY_URL = "http://gjjava.lihexinzhiye.com/api/pay/notifi";
    //退款完成后的回调的地址(如果不要回调信息,可以不配置)
    public static final String REFUND_NOTIFY_URL = "http://gjjava.lihexinzhiye.com/api/refund/notifi";
    //一下代码用于生成签名,写法参考微信支付文档,链接:https://github.com/wechatpay-apiv3/wechatpay-java/blob/main/core/src/test/java/com/wechat/pay/java/core/model/TestConfig.java
    public static final PrivateKey MERCHANT_PRIVATE_KEY;
    public static final String MERCHANT_PRIVATE_KEY_STRING;

    static {
        try {
            MERCHANT_PRIVATE_KEY_STRING = IOUtil.loadStringFromPath(MERCHANT_PRIVATE_KEY_PATH);
            MERCHANT_PRIVATE_KEY = PemUtil.loadPrivateKeyFromString(MERCHANT_PRIVATE_KEY_STRING);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
